<?php
    /**
     * Created by PhpStorm.
     * 版权所有: 2019~2022 [ hhygyl ]
     * Date: 2019/6/26-14:30
     * Link: http://luckyadmin.luckyhhy.cn
     * FileName: AdminBase.php
     * Keys: ctrl+alt+L/ctrl+s(代码格式化) ctrl+J(代码提示) ctrl+R(替换)ALT+INSERT(生成代码(如GET,SET方法,构造函数等) , 光标在类中才生效)
     * CTRL+ALT+O (优化导入的类和包 需要配置) SHIFT+F2(高亮错误或警告快速定位错误)
     * CTRL+SHIFT+Z(代码向前) CTRL+SHIFT+/ (块状注释) ctrl+shift+enter(智能完善代码 如if())
     *
     **************************************************************
     *                                                            *
     *   .=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-.       *
     *    |                     ______                     |      *
     *    |                  .-"      "-.                  |      *
     *    |                 /            \                 |      *
     *    |     _          |              |          _     |      *
     *    |    ( \         |,  .-.  .-.  ,|         / )    |      *
     *    |     > "=._     | )(__/  \__)( |     _.=" <     |      *
     *    |    (_/"=._"=._ |/     /\     \| _.="_.="\_)    |      *
     *    |           "=._"(_     ^^     _)"_.="           |      *
     *    |               "=\__|IIIIII|__/="               |      *
     *    |              _.="| \IIIIII/ |"=._              |      *
     *    |    _     _.="_.="\          /"=._"=._     _    |      *
     *    |   ( \_.="_.="     `--------`     "=._"=._/ )   |      *
     *    |    > _.="                            "=._ <    |      *
     *    |   (_/                                    \_)   |      *
     *    |                                                |      *
     *    '-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='      *
     *                                                            *
     *                    JUST FIND YOUR BUG !                    *
     **************************************************************
     */

    namespace app\common\controller;


    use app\admin\model\Setting;
    use think\Config;
    use think\Controller;

    class AdminBase extends Controller
    {
        protected  static $controller_name; //控制器名称
        protected  static $mode_name; //模快名称
        protected  static $action_name;//方法名称
        protected  static $setting_config;//方法名称
        protected $param;

        protected function _initialize()
        {
            parent::_initialize(); // TODO: Change the autogenerated


            // 请求参数
            $this->param = $this->request->param();

            // 分页基础默认值
            define('PERPAGE', isset($this->param['limit']) ? $this->param['limit'] : 20);
            define('PAGE', isset($this->param['page']) ? $this->param['page'] : 1);

            $this->Load_fun(); // 加载

        }


        /**
         * @author: hhygyl
         * @name: Load_fun
         * @describe:赋值模快名称和控制
         */
        protected function Load_fun(){
           self::$action_name=strtolower($this->request->action());
           self::$controller_name=strtolower($this->request->controller());
           self::$mode_name=strtolower($this->request->module());
           $this->assign(
               ['action'=>self::$action_name,'controller'=>self::$controller_name,'module'=>self::$mode_name]
           );
           $set=new Setting();
           self::$setting_config=$set->getSetting(); //获取设置配置文件


            // 上传配置
            $uploadConfig = Config::get('config.upload');


            // 图片配置
            $this->assign('uploadImgExt', $uploadConfig['image_config']['upload_image_ext']);
            $this->assign('uploadImgSize', $uploadConfig['image_config']['upload_image_size']);
            $this->assign('uploadImgMax', $uploadConfig['image_config']['upload_image_max']);

            // 视频配置
            $this->assign('uploadVideoExt', $uploadConfig['video_config']['upload_video_ext']);
            $this->assign('uploadVideoSize', $uploadConfig['video_config']['upload_video_size']);
            $this->assign('uploadVideoMax', $uploadConfig['video_config']['upload_video_max']);


            $this->assign("Lucky_Name",SYSTEM_NAME); //系统名称
            $this->assign("Version",VERSION); //系统版本
            $this->assign("Site_url",SITE_URL); //系统名称

        }





        /**
         * @return mixed
         * @author: hhygyl
         * @name: _empty
         * @describe:空操作找不到页面
         */
        public function _empty()
        {
            return $this->fetch('public/404');
        }





    }